package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysPeoplecount;
import com.ruoyi.system.service.ISysPeoplecountService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 时间段人流Controller
 * 
 * @author ruoyi
 * @date 2020-10-12
 */
@Controller
@RequestMapping("/system/peoplecount")
public class SysPeoplecountController extends BaseController
{
    private String prefix = "system/peoplecount";

    @Autowired
    private ISysPeoplecountService sysPeoplecountService;

    @RequiresPermissions("system:peoplecount:view")
    @GetMapping()
    public String peoplecount()
    {
        return prefix + "/peoplecount";
    }

    /**
     * 查询时间段人流列表
     */
    @RequiresPermissions("system:peoplecount:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysPeoplecount sysPeoplecount)
    {
        startPage();
        List<SysPeoplecount> list = sysPeoplecountService.selectSysPeoplecountList(sysPeoplecount);
        return getDataTable(list);
    }

    /**
     * 导出时间段人流列表
     */
    @RequiresPermissions("system:peoplecount:export")
    @Log(title = "时间段人流", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysPeoplecount sysPeoplecount)
    {
        List<SysPeoplecount> list = sysPeoplecountService.selectSysPeoplecountList(sysPeoplecount);
        ExcelUtil<SysPeoplecount> util = new ExcelUtil<SysPeoplecount>(SysPeoplecount.class);
        return util.exportExcel(list, "peoplecount");
    }

    /**
     * 新增时间段人流
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存时间段人流
     */
    @RequiresPermissions("system:peoplecount:add")
    @Log(title = "时间段人流", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysPeoplecount sysPeoplecount)
    {
        return toAjax(sysPeoplecountService.insertSysPeoplecount(sysPeoplecount));
    }

    /**
     * 修改时间段人流
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysPeoplecount sysPeoplecount = sysPeoplecountService.selectSysPeoplecountById(id);
        mmap.put("sysPeoplecount", sysPeoplecount);
        return prefix + "/edit";
    }

    /**
     * 修改保存时间段人流
     */
    @RequiresPermissions("system:peoplecount:edit")
    @Log(title = "时间段人流", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysPeoplecount sysPeoplecount)
    {
        return toAjax(sysPeoplecountService.updateSysPeoplecount(sysPeoplecount));
    }

    /**
     * 删除时间段人流
     */
    @RequiresPermissions("system:peoplecount:remove")
    @Log(title = "时间段人流", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysPeoplecountService.deleteSysPeoplecountByIds(ids));
    }
}
